package com.wangle.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pro.bean.Card_Group;
import com.pro.bean.Groups;
import com.pro.bean.Info;
import com.pro.bean.Mark;
import com.wangle.dao.CardGroupImpl;
import com.wangle.dao.GroupImpl;

public class CardGroupServlet extends HttpServlet {

	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	//	response.setContentType("text/html;charset=UTF-8");
		//PrintWriter out = response.getWriter();
		//request.setCharacterEncoding("UTF-8");
//		response.setContentType("text/html,charset=utf-8");
//		response.setHeader("Charset", "utf-8");
//		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		request.setCharacterEncoding("UTF-8");
 
		CardGroupImpl cardi=new CardGroupImpl();
		Groups group=new Groups();
		String groupname=request.getParameter("groupname");	
		groupname = new String(groupname.getBytes("iso-8859-1"), "utf-8");//�����jsp��servlet��ֵ�������
		//System.out.println(groupname);//�ж��Ƿ����
		group.setGroupname(groupname);	
		
		request.setAttribute("groupname", groupname);
		
	    ArrayList<Info> cardlist=cardi.querycard(groupname, true);//ͨ��groupname��ѯ����ͬgroupid 
	    request.setAttribute("cardlist", cardlist);
	    request.getRequestDispatcher("jsp/groupRight.jsp").forward(request, response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html,charset=utf-8");
		response.setHeader("Charset", "utf-8");
		response.setCharacterEncoding("utf-8");
			System.out.println("ɾ��һ������");
			Info info=new Info();
			CardGroupImpl cardi=new CardGroupImpl();
			info.setCardid(Integer.valueOf(request.getParameter("cardid")));
		
			cardi.deletecard(info);	
			//ArrayList cs=cardi.querycard(groupname,true);	
			//request.getSession().setAttribute("group", cardgroup);
			//request.getSession().setAttribute("allQuery", true);

		//}
		
	}


	public void init() throws ServletException {
		// Put your code here
	}

}
